﻿using BTechBids.Web.IDataAdapters.Adapters;
using BTechBids.Web.IDataAdapters.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace BTechBids.Web.Controllers
{
    //[Authorize]
    public class AdminController : ApiController
    {
        IItemAdapter _adapter;

        public AdminController()
        {
            _adapter = new ItemAdapter();
        }

        [ActionName("allitems")]
        public IHttpActionResult GetAllItemsForAdmin()
        {
             if (User.IsInRole("Admin"))
            {
                List<Models.ItemVM> items = _adapter.GetAllItemsForAdmin();
                return Ok(items);
            }
             return Unauthorized();
        }
        [ActionName("allusers")]
        public IHttpActionResult GetAllUsersForAdmin()
        {
            if (User.IsInRole ("Admin"))
            {
                List<Models.UserVM> users = _adapter.GetAllUsers();
                return Ok(users);
            }
            return Unauthorized();
        }
    }
}
